
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 11/10/2018 11:07:33
-- Generated from EDMX file: C:\Users\Administrator\Documents\Visual Studio 2015\Projects\DevFramework\DevFramework.Model\DataModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [TestDB];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'DataDictionary_Type'
CREATE TABLE [dbo].[DataDictionary_Type] (
    [Id] uniqueidentifier  NOT NULL,
    [DisplayName] nvarchar(max)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [CreatePerson] nvarchar(max)  NOT NULL,
    [LastUpdateTime] datetime  NOT NULL,
    [LastUpdatePerson] nvarchar(max)  NOT NULL,
    [IsEnable] bit  NOT NULL,
    [IsDel] bit  NOT NULL,
    [DataCode] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'DataDictionary_Detail'
CREATE TABLE [dbo].[DataDictionary_Detail] (
    [Id] uniqueidentifier  NOT NULL,
    [DisplayName] nvarchar(max)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [CreatePerson] nvarchar(max)  NOT NULL,
    [LastUpdateTime] datetime  NOT NULL,
    [LastUpdatePerson] nvarchar(max)  NOT NULL,
    [IsEnable] bit  NOT NULL,
    [IsDel] bit  NOT NULL,
    [DataCode] nvarchar(max)  NOT NULL,
    [DataDictionary_TypeId] uniqueidentifier  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'DataDictionary_Type'
ALTER TABLE [dbo].[DataDictionary_Type]
ADD CONSTRAINT [PK_DataDictionary_Type]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DataDictionary_Detail'
ALTER TABLE [dbo].[DataDictionary_Detail]
ADD CONSTRAINT [PK_DataDictionary_Detail]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [DataDictionary_TypeId] in table 'DataDictionary_Detail'
ALTER TABLE [dbo].[DataDictionary_Detail]
ADD CONSTRAINT [FK_DataDictionary_TypeDataDictionary_Detail]
    FOREIGN KEY ([DataDictionary_TypeId])
    REFERENCES [dbo].[DataDictionary_Type]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_DataDictionary_TypeDataDictionary_Detail'
CREATE INDEX [IX_FK_DataDictionary_TypeDataDictionary_Detail]
ON [dbo].[DataDictionary_Detail]
    ([DataDictionary_TypeId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------